//
//  MQTTSessionManager.h
//  MQTTNetworkTools
//
//  Created by Yahaong on 16/8/2.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MQTTCoverTool.h"
#import "ZTUser.h"
#import <XAISDK/XAIMQTTDEF.h>
#import "DataManager.h"
#import <XAISDK/XAIPKT.h>
#import <XAISDK/XAIFormatDataCount.h>
#import <XAISDK/XAIJPushRule.h>
#import <XAISDK/XAI.h>

@class Gateway;
#define kMQTTSessionManager [MQTTSessionManager sharedManager]
@interface MQTTSessionManager : NSObject
<
XAIDelegate
>
@property (nullable, nonatomic, strong) ZTUser *currentUser;
@property (nullable, nonatomic, strong) XAIGateway *currentGateway;
@property (nullable, nonatomic, copy)   NSString *registerID;
@property (nonatomic, assign)           XAITYPEAPSN tmpApsn;
@property (nonatomic, assign)          BOOL isLogin;
@property (nonatomic, assign)          BOOL isProtection;
@property (nonatomic, assign)          BOOL isShowJoinView;
@property (nonatomic, assign)          BOOL isSHowHomeed;
@property (nullable, nonatomic, strong) XAI* xai;
@property (nullable, nonatomic, strong) dispatch_queue_t historyMessageQueue;
@property (assign, nonatomic) BOOL netWorkStatus;

+ (instancetype __nullable)sharedManager;
- (void)changeMQTTClinetID:(NSString* __nullable)clientID;
+ (NSString *__nullable)roomListPath;
- (void)sendMyDeviceName:(NSString* __nullable)name;
- (void)sendMyDeviceConnection:(BOOL)online;
- (void)sendMyDevicePower:(uint32_t)power;

- (void)sendStatus:(uint8_t)statusID toApsn:(XAITYPEAPSN)toApsn toLuid:(XAITYPELUID)toLuid dataType:(uint8_t) type bytes:(void* __nullable)bytes length:(int)length;
- (void)sendStatus:(uint8_t)statusID dataType:(XAI_DATA_TYPE) dataType length:(size_t)length  bytes:(void *__nullable)bytes fromApsn:(XAITYPEAPSN) fromApsn fromLuid:(XAITYPELUID)fromLuid toApsn:(XAITYPEAPSN)toApsn toLuid:(XAITYPELUID) toLuid;
- (void)sendMyDev:(uint32_t) type  verson:(uint32_t)verson sleep:(BOOL)sleep;
- (void)sendDeviceDev:(uint32_t) type  verson:(uint32_t)verson sleep:(BOOL)sleep fromApsn:(XAITYPEAPSN)fromApsn fromLuid:(XAITYPELUID)fromLuid;
- (void)deviceAdd:(XAITYPEAPSN) apsn Luid:(XAITYPELUID)luid;
- (void)deviceDelete:(XAITYPEAPSN) apsn Luid:(XAITYPELUID)luid;
- (void )setJPushRule:(uint32_t) apsn registerID:(NSString* __nullable)registerID enable:(BOOL) enable configs:(NSArray <XAIJPushRule*>* __nullable) configs;
- (void)exit;
- (void)changeNewApsn:(XAITYPEAPSN)apsn;
- (void)changeNewApsnAndNotify:(XAITYPEAPSN)apsn;
- (void)sendCmd:(uint8_t)cmdID  toApsn:(XAITYPEAPSN)toApsn toLuid:(XAITYPELUID)toLuid data:(XAIFormatDataCount *__nullable)formatDataCount;
- (void)sendStatus:(uint8_t)statusID  toApsn:(XAITYPEAPSN)toApsn toLuid:(XAITYPELUID)toLuid data:(XAIFormatDataCount *__nullable)formatDataCount;
+ (NSString* __nullable) getTopicHeadFromPkt:(XAIPKT*__nullable )pkt;
- (void)send:(XAIPKT* __nullable)pkt;
@end
